#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>

static int fd = -1;

int init_fan()
{
    fd = open("/dev/gec6818_ptc_drv",O_WRONLY);
    if(fd == -1)
    {
        printf("open fan error\n");
        return fd;
    }

    fan_onOff(0);

    return 0;
}

void fan_onOff(int isOn)
{
    static char user_buff;
    if(user_buff == isOn)
        printf("fan : %d\n", isOn);

    if(isOn)
    {
        user_buff = 1;
    }
    else
    {
        user_buff = 0;
    }
    write(fd,&user_buff,sizeof(user_buff));
}
